home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_01
/
9n01008a
< prev
next >
Wrap
Text File
|
1990-12-02
|
802b
|
52 lines
/* threads1.c */
/* Listing 1 -- An example of an alarm thread */
#include <conio.h>
#include <process.h>
#define INCL_DOSPROCESS
#include <os2.h>
USHORT beeperThreadID;
#define BEEPER_SSIZE 3000
void beeper( void *arg);
int Horn = 0;
void main(void)
{
char c;
beeperThreadID = _beginthread( beeper, NULL,
BEEPER_SSIZE, NULL);
while (c= (char) getch() )
{
if (c == 'a')
Horn = 1;
else if (c == 'c')
Horn = 0;
else if (c == 'x')
break;
}
}
/* "arg" here is a dummy --
just to satify the compiler */
void beeper( void *arg)
{
while (1)
{
if (Horn)
{
DosBeep( 1000, 125);
DosBeep( 750, 125);
}
else
{
DosSleep( 250L);
}
}
}